<template>
  <div class="mobile-layout">
    <!-- Status Bar -->
    <div class="status-bar">
      <span>{{ currentTime }}</span>
      <div class="status-icons">
        <el-icon><Signal /></el-icon>
        <el-icon><Wifi /></el-icon>
        <el-icon><Battery /></el-icon>
      </div>
    </div>

    <!-- Main Content -->
    <div class="content">
      <router-view v-slot="{ Component }">
        <transition name="fade" mode="out-in">
          <component :is="Component" />
        </transition>
      </router-view>
    </div>

    <!-- Navigation Bar -->
    <div class="nav-bar">
      <router-link 
        v-for="item in navItems" 
        :key="item.path"
        :to="item.path"
        class="nav-item"
        :class="{ active: $route.path === item.path }"
      >
        <el-icon><component :is="item.icon" /></el-icon>
        <span>{{ item.title }}</span>
      </router-link>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const currentTime = ref('')

const navItems = [
  { path: '/', title: '生产监控', icon: 'TrendCharts' },
  { path: '/yield', title: '良率分析', icon: 'Percentage' },
  { path: '/equipment', title: '设备维护', icon: 'Setting' },
  { path: '/data-integration', title: '数据集成', icon: 'DataLine' },
  { path: '/system', title: '系统设置', icon: 'Tools' }
]

const updateTime = () => {
  const now = new Date()
  currentTime.value = now.toLocaleTimeString('zh-CN', { 
    hour: '2-digit', 
    minute: '2-digit' 
  })
}

let timer

onMounted(() => {
  updateTime()
  timer = setInterval(updateTime, 1000)
})

onUnmounted(() => {
  clearInterval(timer)
})
</script>

<style lang="scss" scoped>
.mobile-layout {
  width: 100%;
  height: 100vh;
  background-color: #f5f7fa;
  position: relative;
  overflow: hidden;
}

.status-bar {
  height: 44px;
  background-color: #000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 14px;

  .status-icons {
    display: flex;
    gap: 8px;
  }
}

.content {
  height: calc(100vh - 94px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-bar {
  height: 50px;
  background-color: #fff;
  border-top: 1px solid #eee;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 16px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #909399;
  text-decoration: none;
  font-size: 12px;
  padding: 4px 0;

  .el-icon {
    font-size: 20px;
    margin-bottom: 2px;
  }

  &.active {
    color: #409eff;
  }
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style> 